#load "scanner.cmo";;
#use "testlib.ml";;

addtest "SingleValueTokenization"
        (function () -> Scanner.token (Lexing.from_string "integer"))
        (Parser.INT);;

addtest "DifferentValueTokenization"
        (function () -> Scanner.token (Lexing.from_string "real"))
        (Parser.REAL);;

addtest "HeadTokenization"
        (function () -> Scanner.token (Lexing.from_string "integer integer"))
        (Parser.INT);;

addtest "TokenizationHandlesWhitespace"
        (function () -> Scanner.token (Lexing.from_string "   integer  "))
        (Parser.INT);;

addtest "TokenizationRequiresWhitespace"
        (function () -> Scanner.token (Lexing.from_string "integerinteger"))
        (Parser.ID "integerinteger");;

addtest "TokenizationIgnoresComments"
        (function () -> Scanner.token (Lexing.from_string "/*foo*/ integer /*bar*/"))
        (Parser.INT);;

addtest "TokenizationRecognizesInt"
        (function () -> Scanner.token (Lexing.from_string "12"))
        (Parser.LITERAL_INT(12));;

addtest "TokenizationRecognizesReal"
        (function () -> Scanner.token (Lexing.from_string "12.0"))
        (Parser.LITERAL_REAL(12.0));;

addtest "TokenizationRecognizesBool"
        (function () -> Scanner.token (Lexing.from_string "FALSE"))
        (Parser.LITERAL_BOOL(false));;

addtest "TokenizationRecognizesString"
        (function () -> Scanner.token (Lexing.from_string "\"Hello\""))
        (Parser.LITERAL_STR("Hello"));;

addtest "TokenizationRecognizesStringWithSpace"
        (function () -> Scanner.token (Lexing.from_string "\"Hello World\""))
        (Parser.LITERAL_STR("Hello World"));;

runtests();;
